﻿@model IEnumerable<iDMS.Models.Drawing>
@using MvcHtmlHelpers
@{
    ViewBag.Title = "Index";
}
<script type="text/javascript">
    $(function () {
        $("a.action").button();

        $('#email').hover(
					function () { $(this).addClass('ui-state-hover'); },
					function () { $(this).removeClass('ui-state-hover'); }
				);

    });

    
</script>
<h3>
    Drawings - <span class="accent">Index</span>
</h3>
<fieldset>
    <legend>Search for Drawing:</legend>
    @using (Html.BeginForm("Index", "Drawing", FormMethod.Get))
    {   <span class="display-label"> Identifier or name:</span> @Html.TextBox("search", null, new { @class = "searchTextBox" });
        <input type="submit" value="Search" />
    }
</fieldset>

<div id="list">
    <table>
        <tr>
            <th>
            </th>
            <th>
                Identifier
            </th>
            <th>
                Name
            </th>
            <th>
                Manufacturer
            </th>
            <th>
                Design Change
            </th>
            <th>
                Innaplicable
            </th>
        </tr>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.ActionLink("Sheets", "Sheets", new { id = item.DrawingID }, new { @class = "action" })
                    @Html.ActionLink("Details", "Details", new { id = item.DrawingID }, new { @class = "action" })
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Identifier)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Name)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.Manufacturer.Name)
                    @Html.CountryFlag(item.Manufacturer.Country.ISO3166Alfa2)
                    @Html.ManufacturerDetailsActionLink(item.Manufacturer)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.DesignChange.Identifier)
                    @Html.IconActionLink("Details", "DesignChange", new { id = item.DesignChangeID }, "", "ui-icon-search")
                    @Html.DesignChangeDetailsActionLink(item.DesignChange)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.DesignChange1.Identifier)
                    @if (item.InnaplicableDesignChangeID.HasValue)
                    {
                        @Html.IconActionLink("Details", "DesignChange", new { id = item.InnaplicableDesignChangeID }, "", "ui-icon-search")
                    }                    
                    @Html.DesignChangeDetailsActionLink(item.DesignChange1)
                </td>
            </tr>
        }
    </table>
</div>

<p>
    @Html.ActionLink("Create New Drawing", "Create", null, new { @id = "CreateLink" })
</p>

@Html.Partial("_AjaxDialog")
